package com.jintoufs.dao.baseinfo.impl;

import com.jintoufs.dao.MyBatisSupport;
import com.jintoufs.dao.QueryFilters;
import com.jintoufs.dao.baseinfo.VendorDAO;
import com.jintoufs.domain.baseinfo.Vendor;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Repository
public class VendorDAOImpl extends MyBatisSupport<VendorDAO, Vendor> implements VendorDAO {

    @SuppressWarnings("serial")
    private static Map<String, Object> fildMap = new HashMap<String, Object>() {
        {
            put("id", "v.id");
            put("name", "v.name");
            put("address", "v.address");
            put("phone", "v.phone");
            put("postCode", "v.post_code");
            put("createBy", "v.create_by");
            put("createTime", "v.create_time");
            put("businessScope", "v.business_scope");
            put("businessLicense", "v.business_license");
            put("linkMan", "v.link_man");
            put("code", "v.code");
            put("endTime", "v.end_time");
            put("email", "v.email");
        }
    };

    @Override
    public List<Map<String, Object>> getByFilter(QueryFilters filters_) {
        filters_.format(fildMap);
        return getMapper().getByFilter(filters_);
    }

    @Override
    public void delete(Integer id) {
        getMapper().delete(id);
    }

    @Override
    public void update(Vendor vendor) {
        getMapper().update(vendor);
    }

    @Override
    public void save(Vendor vendor) {
        getMapper().save(vendor);
    }

    @Override
    public List<Vendor> queryByParams(Map<String, Object> params) {
        return getMapper().queryByParams(params);
    }
}